package com.foreveross.service;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.foreveross.common.Constants;
import com.foreveross.dao.DDManagerDAO;
import com.foreveross.dao.LogDAO;
import com.foreveross.vo.HrCode;
import com.foreveross.vo.Log;
import com.foreveross.vo.SysUser;

@Service("logService")
@Transactional
public class LogService {

	@Resource
	public LogDAO logDAO;

	public long getLogListCount(String type, String creater) throws Exception {
		return logDAO.findLogListCount(type, creater);
	}

	public List<Log> findLogList(String type, String creater, int pageIndex,
			int pageSize) throws Exception {
		return logDAO.findLogList(type, creater, pageIndex, pageSize);
	}
 
	public void saveLog(String ip,Integer operateType,int type, String title, String creater, String content)
			throws Exception {
			Log log = new Log();
			log.setIp(ip);
			log.setOperateType(operateType);
			log.setTitle(title);
			log.setType(type);
			log.setCreateTime(new Date());
			log.setCreater(creater!=null?new SysUser(creater):null);
			log.setContent(content);
			logDAO.save(log);
	}

}
